package spike.jdbc;

import java.io.File;

import spike.jdbc.model.Title;

public class TitleParser {

	public TitleParser() {
	}

	public Title parse(File aMp3File) {
		String vNomCourt = aMp3File.getName();

		String nom = null;
		String artiste = null;
		String album = null;

		int holder;
		int held_lgth;
		held_lgth = vNomCourt.length();
		holder = vNomCourt.lastIndexOf('.', held_lgth);
		vNomCourt = vNomCourt.substring(0, holder);

		// StringTokenizer st = new StringTokenizer(vNomCourt, "-");
		holder = vNomCourt.indexOf('-', 0);
				
		artiste = vNomCourt.substring(0, holder);
		album = "unknown";
		
		held_lgth = vNomCourt.length();
		nom = vNomCourt.substring(holder + 1, held_lgth);
		
		artiste.trim();
		nom.trim();
		
		return new Title(nom, artiste, album);
	}

}
